/*
 * Cyclometer.h
 *
 * The controller of the system that interfaces
 * the state machine with the input/output interfaces
 * of the system.
 *
 * Author: Zachary Masiello
 * Author: Peter-John Rowe
 */

#ifndef CYCLOMETER_H_
#define CYCLOMETER_H_

#include "AllButtonPressEvent.h"
#include "ModeButtonPressEvent.h"
#include "SetButtonPressEvent.h"
#include "SSModeButtonPressEvent.h"
#include "SSButtonPressEvent.h"
#include "UnitSetEvent.h"

#include "LEDLight.h"
#include "LEDDisplay.h"
#include "Calculator.h"

#include "StateTable.h"
#include "Transition.h"
#include "IEvent.h"

using namespace std;
class IState;
class Cyclometer
{
public:
	// Constructor
	Cyclometer(Calculator *, LEDDisplay *);
	// Destructor
	~Cyclometer();
	// Accepts an event and passes it to the state table
	void accept(IEvent* event);
	// Gets the state table
	StateTable* getStateTable();
	// Initiates the state machine
	void run();
	// Triggers the calculator to change the calculation mode (auto/manual)
	void changeCalcMode();
	// Gets the distance calculated by the calculator,
	// and trigger the LED Display to display it
	void displayDistance();
	// Displays the speed
	void displaySpeed();
	// Displays the time
	void displayTime();
	// Increment tire size and display new tire size
	void incrementTireSize();
	// Initial action to be done
	void initialAction();
	// Triggers the calculator to do a full reset
	void fullDataReset();
	bool isCalcModeM();
	// Evaluates the measurement units to see if its in
	// kilometers
	bool isUnitK();
	// Evaluates the measurement units to see if its in
	// miles
	bool isUnitM();
	// Triggers the calculator to perform a data reset
	void resetTripValues();
	// Sets the unit and dispays it
	void setUnit();
	// Sets wheel circumference and displays it
	void setWheelCircum();
	// Triggers the calculator to start/stop calculation
	void startStopCalc();
	// Testing state machine
	void testStateMachine();
	// Gets the circumference and displays it
	void getAndDisplayCircumference();
private:
	// State table
	StateTable* table;
	// Calculator
	Calculator* calculator;
	// Seven Segment display
	LEDDisplay* ledDisplay;
	// Sets the initial state
	void setDefaultInitialState(IState* initial);
	// Creates the state table
	void createStateTable();
	// Assigns a state to the state table
	void assignState(IState* state);
	// Assigns a transition to the state table
	void assignTransition(IState* state,Transition* tran);
};

#endif /* CYCLOMETER_H_ */
